<template>
  <div class="my_l">
    <header class="top_bar">
      <h3 class="cartname">付款页面</h3>
    </header>
    <main class="user_login_box">
      <div class="login_dialog">

        <div style="font-size: 12px; margin-bottom: -3%; margin-left: 2%; display: block; color: rgb(136, 136, 136);">金额:</div>
        <div class="_username" v-bind:style="{ display: intypeDisplay}">
          <input type="number" readonly="readonly" name="integral" placeholder="请输充值积分的数量" class="user_input" v-model="amount" />
        </div>
        <div class="_username" v-show="false" v-bind:style="{ display: intypeDisplay}">
          <input type="text" name="reason" placeholder="请输充值的原因" class="user_input" v-model="reason" />
        </div>

        <div v-bind:style="{ display: intypeDisplay}" style="margin:20px 0px 0px 0px; ">
          <mt-radio title="支付方式:" v-model="payType" :options="radio_options">
          </mt-radio>
        </div>

        <div class="login_box" v-bind:style="{ display: intypeDisplay}">
          <a @click="goPay()" class="btn_login">支付</a>
        </div>

      </div>
    </main>
  </div>

</template>
<script>
import { Radio, MessageBox } from "mint-ui";
export default {
  data() {
    return {
      typeDisplay: "none",
      intypeDisplay: "block",
      username: "",
      mobile: "",
      reason: "购买商品",
      amount: "",
      orderSn: "",
      payType_options: [
        {
          value: "1",
          label: "支付宝"
        },
        {
          value: "2",
          label: "微信"
        }
      ],
      payType: "1",

      radio_options: [
        {
          label: "支付宝",
          value: "1"
        },
        {
          label: "微信",
          value: "2"
        }
      ],

      adminId: "",
      mechanismId: ""
    };
  },
  mounted() {
    this.getUDatas();
  },
  methods: {
    getUDatas() {
      let _this = this;
      _this.$store.dispatch("hideLoading");
      _this.amount = JSON.parse(window.sessionStorage.totalMoney);
      if (window.sessionStorage.userInfo) {
        let uObj = JSON.parse(window.sessionStorage.userInfo);
        console.log(uObj);
        this.adminId = uObj.id;
        this.mechanismId = uObj.mechanismId;
        this.orderSn = this.$route.query.orderSn;
      } else {
        _this.$router.push({
          path: "/login"
        });
      }
    },
    //支付
    goPay() {
      let _this = this;
      console.log(_this);
      //用户存在，根据paytype充值
      if (_this.payType == "1") {
        //  this.$router.push({path: '/pay'});
        window.location.href =
          "./src/components/alipay/pay.html?mobile=" +
          this.mobile +
          "&amount=" +
          this.amount +
          "&orderSn=" +
          this.orderSn +
          "&reason=" +
          this.reason +
          "&money=" +
          this.amount +
          "&payType=1" +
          "&adminId=" +
          this.adminId +
          "&type=6" +
          "&mechanismId=" +
          this.mechanismId;
      }
      if (_this.payType == "2") {
        window.sessionStorage.jumptype = "1";
        //微信付款
        this.$router.push({
          path: "/wxpay",
          query: {
            mobile: this.mobile,
            amount: this.amount,
            reason: this.reason,
            payType: "2",
            type: "6",
            orderSn: this.orderSn,
            money: this.amount,
            integral: this.integral,
            adminId: this.adminId,
            mechanismId: this.mechanismId
          }
        });

        
      }
    }
  }
};
</script>

<style>
@import "../assets/css/login.css";
</style>